//01背包问题

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <climits>
#include <vector>
#define int long long
#define x first 
#define y second 
using namespace std;
const int N = 55;
int dp[N][510][510];
int a[N],b[N],c[N];

void solve()
{
    int n;
    cin >> n;
    int T,H;
    cin >> T >> H;
    for(int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];
    
    for(int i = 0; i <= n; i++) dp[i][0][0] = 0;

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= T; j++) 
        {
            for(int k = 1; k <= H; k++)
            {
                //if(i == 1 && !((j < a[i]) || (k < b[i])))   dp[i][j][k] = c[i];
                //else if(i == 1) continue;
                if(a[i] > j || b[i] > k)  dp[i][j][k] = dp[i - 1][j][k];
                else dp[i][j][k] = max(dp[i - 1][j][k] , dp[i - 1][j - a[i]][k - b[i]] + c[i]);
            }
        }
    }
    cout << dp[n][T][H] << endl;

}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t = 1;
    while(t -- ) solve();
    return 0;
} 
 